//
//  LoadingView.m
//  W2MD
//
//  Created by zhudongwei on 14/12/2.
//  Copyright (c) 2014年 zhudongwei. All rights reserved.
//

#import "LoadingView.h"

@implementation LoadingView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)startAnimation
{
    if (_isStop) {
        return;
    }
    
    //[UIView animateWithDuration:0.5 delay:0.5 options:UIViewAnimationOptionCurveEaseIn  animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>];
    [self hiddenAll];
    [UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionCurveEaseIn  animations:^{
        self.im1.alpha = 0.2;
    } completion:^(BOOL finished) {
        if (finished) {
            [UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionCurveEaseIn  animations:^{
                self.im2.alpha = 0.4;
            } completion:^(BOOL finished) {
                if (finished) {
                    [UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionCurveEaseIn  animations:^{
                        self.im3.alpha = 0.6;
                    } completion:^(BOOL finished) {
                        if (finished) {
                            [UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionCurveEaseIn  animations:^{
                                self.im4.alpha = 0.7;
                            } completion:^(BOOL finished) {
                                if (finished) {
                                    [UIView animateWithDuration:0.2 delay:0.2 options:UIViewAnimationOptionCurveEaseIn  animations:^{
                                        self.im5.alpha = 1.0;
                                    } completion:^(BOOL finished) {
                                        if (finished) {
                                            [self startAnimation];
                                        }
                                    }];
                                }
                            }];
                        }
                    }];
                }
            }];
        }
    }];
    

}
-(void)hiddenAll
{
    self.im1.alpha = 0.f;
    self.im2.alpha = 0.f;
    self.im3.alpha = 0.f;
    self.im4.alpha = 0.f;
    self.im5.alpha = 0.f;
    
}
@end
